﻿
using System;
using System.Collections.Generic;
using System.Text;

using YouHP.Utility;
using YouHP.BLL;
using YouHP.Model;
using YouHP.Model.Group;
using System.Web;

namespace YouHP.Pages.BBS
{
    public class NewsList:BoardBasePage
    {
        protected override void ShowPage()
        {
            base.ShowPage();
            if (ErrorCount > 0) return;

            HandleCommon();
            if (ErrorCount > 0) return;

            if (IsPost) HandlePost();
            else HandleGet();
        }

        protected List<GroupNewsInfo> NewsDataList;
        protected List<ActionInfo> ActionLatestList;
        protected List<GroupInfo> groupListHotest;
        protected int PageCount;
        protected int PageIndex = 1;
        protected string PagingString = "";
        protected int DataCount = 0;

        protected void HandleCommon()
        {
            this.AddLocation("版块新闻列表", "/BBS/NewsList.aspx?gid=" + GroupData.Id);
        }

        protected void HandlePost()
        {

        }

        protected void HandleGet()
        {

            ActionLatestList = ActionBLL.Instance.GetLattestHugBookList(Config.ActionLatestNum);
            groupListHotest = GroupBLL.Instance.GetGroupListHotest(Config.GroupHottestNum);

            NewsDataList = GroupNewsBLL.Instance.GetGroupNewsList(GroupData.Id,Config.GroupNewPageSize, PageIndex, out PageCount);

            PageCount = Utils.GetPageCount(DataCount, Config.GroupNewPageSize);

            string query = HttpContext.Current.Request.Url.Query;
            query = Utils.RemoveQueryItem(query, "page");

            PagingString = this.GetPagingString(
                PageIndex,
                PageCount,
                "/BBS/NewsList.aspx" + query, "page");
        }
    }
}